package com.xykj.web.controller;

import com.xykj.common.exception.BusinessException;
import com.xykj.common.response.Response;
import com.xykj.pojo.dto.NewStockCalendarDto;
import com.xykj.pojo.dto.NewsFlashDto;
import com.xykj.service.NewsFlashService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * @ClassDescription: 证券快讯表Controller层
 * @author:yzh
 * @create:2025/5/12 22:19
 **/
@RestController
@RequestMapping("/news-flash")
public class NewsFlashController {
    @Autowired
    private NewsFlashService newsFlashService;

    @GetMapping("/getNewsFlash")
    public Response getNewsFlash(@RequestParam Integer pageNum, @RequestParam Integer  pageSize){
        if(pageSize==null||pageNum==null){
            throw new BusinessException("页面大小和页号不能为空");
        }
        List<NewsFlashDto> newsFlashDtos = newsFlashService.queryNewsFlash(pageNum, pageSize);
        Integer count = newsFlashService.totalNewsFlash();
        HashMap<String, Object> map = new HashMap<>();
        map.put("results",newsFlashDtos);
        map.put("total",count);
        return Response.success("查询成功",map);
    }
}
